import axios from 'axios';
import {isObject,each,isArray} from '../utils/index';

export default (data)=> {
    var _formData = new FormData();//将model转为表单格式
    each(data.formData,function(key,value){
        _formData.append(key,value);
    });
    _formData.append(data.alias,data.file, data.filename);
    var obj = {
        baseURL:data.url,
        url:'',
        method: 'post',
        headers: {'Content-Type':'multipart/form-data'},
        data:_formData,
        responseType: 'json',
        onUploadProgress: function (progressEvent) {
            data.progress(progressEvent)
        }
    };
    return axios.request(obj).then(function (res) {
        return res.data
    })
}